import 'dart:convert';

import 'package:tencent_kit/tencent_kit.dart';

const String _kTencentAppID = '102733410';
const String _kUniversalLink =
    'https://www.goodsqi.com/qq_conn/102733410/*'; // 可选项目

class EcyQQUtil {
  static init() async {
    await TencentKitPlatform.instance
        .registerApp(appId: _kTencentAppID, universalLink: _kUniversalLink);
    await TencentKitPlatform.instance.setIsPermissionGranted(granted: true);
  }

  static shareText(String txt) async {
    await TencentKitPlatform.instance
        .registerApp(appId: _kTencentAppID, universalLink: _kUniversalLink);
    await TencentKitPlatform.instance.setIsPermissionGranted(granted: true);
    Map<String, dynamic> shareObj = json.decode(txt);
    await TencentKitPlatform.instance.shareWebpage(
        scene: TencentScene.kScene_QQ,
        title: shareObj["shareTitle"],
        imageUri: Uri.parse(shareObj["shareImageUrl"] ?? ""),
        targetUrl: shareObj["shareUrl"] ?? "");
  }
}
